// const TStudentModel = require("../models/tStudent")(
//   require("../config/sequelizeConf")
// );
const model = require("../config/model");

module.exports = {
  async getAllStudents(req, res) {
    res.send(
      await model.tStudent.findAll({
        // where: {
        //   s_id: "234",
        //   s_name: "2313",
        //   s_sex: "24",
        // },
        attributes: ["s_id", "s_name", "s_sex"], //  需要查询出的字段
        // limit: 10, //  查询多少条
        // offset: 0, //  查询开始位置
        // raw:true //这个可以让sequelize查询初来的数据不被包装,从而我们可以在后期处理数据返回前端
      })
    );
  },
  async seachStudents(req, res) {
    let { name, sex, num } = req.body;

    let result = await model.tStudent.findAll({
      where: {
        // s_id: num ?  : "",
        // s_name: "" ? name : "",
        // s_sex: "" ? sex : "",
      },
      attributes: ["s_id", "s_name", "s_sex"],
    });
    console.log(result);
    res.send(result);
  },
};
//参考:https://segmentfault.com/a/1190000019760817
